﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace Day22EF
{
    public static class SelectListExtensions
    {
        public static SelectList ToSelectList<T, TValue>(
                this IEnumerable<T> collection,
                Expression<Func<T, TValue>> valueExp,
                Expression<Func<T, TValue>> textExp,
                object selectedValue
            )
        {
            return new SelectList(collection,
                ExpressionHelper.GetExpressionText(valueExp),
                ExpressionHelper.GetExpressionText(textExp), selectedValue);
        }
    }
}